package com.uenpay.oem.ui.register;

import android.text.TextUtils;
import android.util.Log;

import com.qiyunxin.android.http.HttpInvokeResultCode;
import com.socks.library.KLog;
import com.uenpay.im.IMApplication;
import com.uenpay.im.ui.old.activity.login.LoginAndRegisterHandle;

/**
 * Created by PS on 2017/6/26.
 */

public class RegisterPresenter implements RegisterContract.Presenter {

	private final LoginAndRegisterHandle loginAndRegisterHandle;
	private final RegisterContract.View Mregisterview;


	public RegisterPresenter(RegisterContract.View view) {
		Mregisterview = view;
		loginAndRegisterHandle = new LoginAndRegisterHandle();
	}

	/**
	 * 检查手机号是否注册过
	 *
	 * @param number
	 */
	@Override
	public void isPhoneRegister(String number) {

		loginAndRegisterHandle.checkMobileIsRegister(number, new LoginAndRegisterHandle.IResetPwdResultListener() {
			@Override
			public void onResult(int status, String msg) {

				if (status == HttpInvokeResultCode.RESULT_OK) {
					// 手机号检测成功
					Mregisterview.Phonelegal();
				} else {
					IMApplication.showToast(msg);
				}
			}
		});
	}

	/**
	 * 发送验证码
	 * @param number
     */
	@Override
	public void Sendauthcode(String number) {
		KLog.d("Sendauthcode"+1);
		loginAndRegisterHandle.getRegisterCaptcha(number, "1",

				new LoginAndRegisterHandle.IRegisterCaptchaResultListener() {

					@Override
					public void onRegisterCaptchaResult(int status, String msg,
														String vercode) {
						if (status == HttpInvokeResultCode.RESULT_OK) {
							// 发送成功

						} else {
								IMApplication.showToast(msg);
						}
					}
				});
	}

	@Override
	public void onStart() {

	}

	@Override
	public void onDestroy() {

	}
}
